package com.ym.shardingsphere.controller;

import com.ym.shardingsphere.service.ITxOrderService;
import com.ym.utils.*;
import com.ym.utils.annotation.*;
import com.ym.utils.enums.*;
import com.ym.utils.exception.*;
import com.ym.shardingsphere.vo.TxOrderVO;
import com.ym.utils.restful.AjaxJson;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @version v1.0
 * @ProjectName: SpringCloud-Alibaba-YM
 * @ClassName: TxOrderController
 * @Description: TODO(订单分库分表演示Controller)
 * @Author: 晨曦
 * @Date: 2020-12-21 9:48:12
 */
@Api(value = "订单分库分表演示", tags = {"订单分库分表演示Controller"})
@RestController
@RequestMapping("/TxOrderController")
public class TxOrderController extends BaseController {

    @Autowired
    private ITxOrderService TxOrderService;

    /**
     * @throws CustomException
     * @Title addTxOrder
     * @Description TODO(订单分库分表演示新增)
     * @Params [TxOrderVO]
     * @Return com.ym.utils.AjaxJson
     * @Author 晨曦
     * @Date 2020-12-21 9:48:12
     */
    @Log(title = "订单分库分表演示新增", businessType = BusinessType.INSERT)
    @ApiOperation(value = "订单分库分表演示新增", notes = "描述：订单分库分表演示新增", httpMethod = "POST")
    @RequestMapping(value = "/add/TxOrder", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public AjaxJson addTxOrder(@RequestBody TxOrderVO parmEntityVO) throws CustomException {
        //parmEntityVO.setAddUserId(getLoginUserINfor().getUid());
        return new AjaxJson().Success(TxOrderService.addTxOrder(parmEntityVO));
    }


    /**
     * @throws CustomException
     * @Title deleteTxOrderById
     * @Description TODO(订单分库分表演示删除)
     * @Params [TxOrderVO]
     * @Return com.ym.utils.AjaxJson
     * @Author 晨曦
     * @Date 2020-12-21 9:48:12
     */
    @Log(title = "订单分库分表演示删除", businessType = BusinessType.INSERT)
    @ApiOperation(value = "订单分库分表演示id删除(单条)", notes = "描述：订单分库分表演示id删除(单条)", httpMethod = "POST")
    @RequestMapping(value = "/delete/TxOrderById", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public AjaxJson deleteTxOrderById(@RequestParam(required = true, defaultValue = "") String id) throws CustomException {
        //parmEntityVO.setAddUserId(getLoginUserINfor().getUid());
        TxOrderService.deleteTxOrderById(id);
        return new AjaxJson().Success();
    }


    /**
     * @throws CustomException
     * @Title deleteTxOrderByIds
     * @Description TODO(订单分库分表演示批量删除)
     * @Params [List<String>]
     * @Return com.ym.utils.AjaxJson
     * @Author 晨曦
     * @Date 2020-12-21 9:48:12
     */
    @Log(title = "订单分库分表演示批量删除删除", businessType = BusinessType.INSERT)
    @ApiOperation(value = "订单分库分表演示批量删除(多条)", notes = "描述：订单分库分表演示批量删除(多条)", httpMethod = "POST")
    @RequestMapping(value = "/delete/TxOrderByIds", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public AjaxJson deleteTxOrderByIds(@RequestBody List<String> idList) throws CustomException {
        //parmEntityVO.setAddUserId(getLoginUserINfor().getUid());
        TxOrderService.deleteTxOrderByIds(idList);
        return new AjaxJson().Success();
    }

    /**
     * @throws CustomException
     * @Title updateTxOrder
     * @Description TODO(订单分库分表演示修改)
     * @Params [TxOrderVO]
     * @Return com.ym.utils.AjaxJson
     * @Author 晨曦
     * @Date 2020-12-21 9:48:12
     */
    @Log(title = "订单分库分表演示修改", businessType = BusinessType.UPDATE)
    @ApiOperation(value = "订单分库分表演示修改", notes = "描述：订单分库分表演示修改", httpMethod = "POST")
    @RequestMapping(value = "/update/TxOrder", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public AjaxJson updateTxOrder(@RequestBody TxOrderVO parmEntityVO) throws CustomException {
        //parmEntityVO.setLastUpdateUserId(getLoginUserINfor().getUid());
        return new AjaxJson().Success(TxOrderService.updateTxOrder(parmEntityVO));
    }

    /**
     * @throws CustomException
     * @Title getTxOrderInforById
     * @Description TODO(Id查询订单分库分表演示信息)
     * @Params [id]
     * @Return com.ym.utils.AjaxJson
     * @Author 晨曦
     * @Date 2020-12-21 9:48:12
     */
    @ApiOperation(value = "Id查询订单分库分表演示信息", notes = "描述：Id查询订单分库分表演示信息-单条", httpMethod = "POST")
    @ApiParam(name = "id", value = "主键id", defaultValue = "", required = true)
    @RequestMapping(value = "/get/TxOrderInforById", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public AjaxJson getTxOrderInforById(@RequestParam(required = true, defaultValue = "") String id) throws CustomException {
        return new AjaxJson().Success(TxOrderService.getTxOrderInforById(id));
    }

    /**
     * @throws CustomException
     * @Title getTxOrderListByPage
     * @Description TODO(分页查询订单分库分表演示信息)
     * @Params [parmEntityVO]
     * @Return com.ym.utils.AjaxJson
     * @Author 晨曦
     * @Date 2020-12-21 9:48:12
     */
    @ApiOperation(value = "分页查询订单分库分表演示信息", notes = "描述：分页查询订单分库分表演示信息", httpMethod = "POST")
    @RequestMapping(value = "/get/TxOrderListByPage", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public AjaxJson getTxOrderListByPage(@RequestBody TxOrderVO parmVO,
                                         @RequestParam(required = true, defaultValue = "1", name = "pageNum") Integer pageNum,
                                         @RequestParam(required = true, defaultValue = "10", name = "pageSize") Integer pageSize) throws CustomException {
        return new AjaxJson().Success(TxOrderService.getTxOrderListByPage(parmVO, pageNum, pageSize));
    }

    /**
     * @throws CustomException
     * @Title getSfeManagerMapdataCityListByPage
     * @Description TODO(根据条件检索订单分库分表演示信息)
     * @Params [parmEntityVO]
     * @Return com.ym.utils.AjaxJson
     * @Author 晨曦
     * @Date 2020-12-21 9:48:12
     */
    @ApiOperation(value = "根据条件检索订单分库分表演示信息", notes = "描述：根据条件检索订单分库分表演示信息", httpMethod = "POST")
    @RequestMapping(value = "/get/TxOrderListByParm", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    public AjaxJson getTxOrderListByParm(@RequestBody TxOrderVO parmVO) throws CustomException {
        return new AjaxJson().Success(TxOrderService.getTxOrderListByParm(parmVO));
    }

}
